<?php

namespace common\models;

use Yii;
use common\models\SysUsers;

/**
 * This is the model class for table "dh_sys_user_log".
 *
 * @property integer $id
 * @property integer $uid
 * @property string $operation
 * @property string $remark
 * @property string $ip
 * @property integer $create_time
 */
class SysUserLogs extends \common\components\activeRecord2015
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'dh_sys_user_log';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['uid', 'operation'], 'required'],
            [['uid', 'create_time'], 'integer'],
            [['operation', 'remark'], 'string', 'max' => 120],
            [['ip'], 'string', 'max' => 30]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'uid' => '姓名ID',
            'operation' => '行为',
            'remark' => '备注',
            'ip' => 'Ip地址',
            'create_time' => '时间',
        ];
    }
    
    public static function GetUserName($uid){
        
        $res = SysUsers::findOne([ 'id' => $uid]); 
        $temp = $res['truename'];
        if($temp == ''){
          $temp =  $res['phone'];
        }     
        return $temp;
    }
}
